---
layout: "default"
title: "ExpressibleByBooleanLiteral"
description: "Swift documentation for 'ExpressibleByBooleanLiteral': A type that can be initialized with the Boolean literals true and."
keywords: "ExpressibleByBooleanLiteral,protocol,swift,documentation,BooleanLiteralType"
root: "/v3.0"
---

<div class="intro-declaration"><code class="language-swift">protocol ExpressibleByBooleanLiteral</code></div>

<div class="discussion comment">
    <p>A type that can be initialized with the Boolean literals <code>true</code> and
<code>false</code>.</p>

<p>Only three types provided by Swift---<code>Bool</code>, <code>DarwinBoolean</code>, and
<code>ObjCBool</code>---are treated as Boolean values. Expanding this set to include
types that represent more than simple Boolean values is discouraged.</p>

<p>To add <code>ExpressibleByBooleanLiteral</code> conformance to your custom type,
implement the <code>init(booleanLiteral:)</code> initializer that creates an instance
of your type with the given Boolean value.</p>
</div>

<table class="standard">
<tr>
<th id="inheritance">Inheritance</th>
<td>
<span class="viz"><a href="hierarchy/">View Protocol Hierarchy &rarr;</a></span>
</td>
</tr>

<tr>
<th id="aliases">Associated Types</th>
<td>
<span id="aliasesmark"></span>
<div class="declaration">
<code class="language-swift">BooleanLiteralType</code>
<div class="comment">
    <p>A type that can represent a Boolean literal, such as <code>Bool</code>.</p>
</div>
</div>
</td>
</tr>


<tr>
<th>Import</th>
<td><code class="language-swift">import Swift</code></td>
</tr>

</table>


<h3>Initializers</h3>
<div class="declaration" id="init-booleanliteral_">
<a class="toggle-link" data-toggle="collapse" href="#comment-init-booleanliteral_">init(<wbr>booleanLiteral:)</a> <span class="required">Required</span><div class="comment collapse" id="comment-init-booleanliteral_"><div class="p">
    <p>Creates an instance initialized to the given Boolean value.</p>

<p>Do not call this initializer directly. Instead, initialize a variable or
constant using one of the Boolean literals <code>true</code> and <code>false</code>. For
example:</p>

<pre><code class="language-swift">let twasBrillig = true</code></pre>

<p>In this example, the assignments to the <code>twasBrillig</code> constant calls this
Boolean literal initializer behind the scenes.</p>

<p><strong><code>value</code>:</strong>  The value of the new instance.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(booleanLiteral value: Self.BooleanLiteralType)</code>

    </div></div>
</div>







